package org.json;

import org.junit.Test;

import java.util.List;

import static java.util.Arrays.*;
import static org.json.JsonObjectifier.*;
import static org.junit.Assert.*;

public class WildcardFinderTest {

    @Test
    public void findsNodesByName() throws Exception {
        JSONObject json = new JSONObject("" +
                "{" +
                "   monkey: {" +
                "       woof: \"bark\"," +
                "       food: {" +
                "           sausage: 3.14," +
                "           banana: \"Elephant\"" +
                "       }," +
                "       banana: {" +
                "           yellow: 9.9" +
                "       }," +
                "       apple: \"wasp\"" +
                "   }" +
                "}"
        );

        List<Object> expected = asList(new JSONObject().put("yellow", 9.9), "Elephant");

        List<Object> actual = new WildcardFinder(json).find("banana");

        assertEquals(jsonEquable(expected), jsonEquable(actual));
    }
}